package com.workmanager.service;

import com.workmanager.bean.EvaluateBean;
import com.workmanager.bean.FeedbackBean;
import com.workmanager.bean.JobTaskBean;
import com.workmanager.mapper.StudentMessageMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/9/4 0004.
 */
@Service("messageStudentService")
public class MessageStudentService {
    @Resource(name="studentMessageMapper")
    private StudentMessageMapper studentMessageMapper;

    public StudentMessageMapper getStudentMessageMapper() {
        return studentMessageMapper;
    }

    public void setStudentMessageMapper(StudentMessageMapper studentMessageMapper) {
        this.studentMessageMapper = studentMessageMapper;
    }

    /***
     * 获取所有消息
     * 学生id@param student_id
     * 所有消息map@return
     */
    public Map<String, Object> getAll(String student_id){
        List<JobTaskBean> listJobTask = getJobTask(student_id);
        List<EvaluateBean> listEvaluate = getEvaluate(student_id);
        Map<String,Object> mapMsg = new HashMap<String ,Object>();
        mapMsg.put("jobTask",listJobTask);
        mapMsg.put("evaluate",listEvaluate);
        return mapMsg;
    }

    /***
     * 获取作业任务通知
     * 学生id@param student_id
     * 作业任务列表@return
     */
    public List<JobTaskBean> getJobTask(String student_id){
        return studentMessageMapper.getJobTask(student_id);
    }

    /***
     * 获取作业评价
     * 学生id@param student_id
     * 作业评价列表@return
     */
    public List<EvaluateBean> getEvaluate(String student_id){
        return studentMessageMapper.getEvaluate(student_id);
    }
    public boolean answer(FeedbackBean feedback){
        feedback.setFeedback_id(studentMessageMapper.getFeedbackKey());
        return studentMessageMapper.answer(feedback)==1?true:false;
    }
}
